use crate::kernel::os_kernel_get_tick_count;
use core::time::Duration;

pub struct Instant {
    tick: u32,
}


impl Instant {

    pub fn now() -> Self {
        Self { tick: os_kernel_get_tick_count() }
    }

    pub fn duration(&self) -> Duration {
        Duration::from_millis(os_kernel_get_tick_count().wrapping_sub( os_kernel_get_tick_count() ) as u64)
    }

    pub fn duration_ms(&self) -> u32 {
        os_kernel_get_tick_count().wrapping_sub( self.tick )
    }

    pub fn is_after_ms(&self, ms: u32) -> bool {
        os_kernel_get_tick_count().wrapping_sub(self.tick) >= ms
    }
}




